package klass.parse.domain.constant;

import java.util.List;

public abstract class ConstantClassMemberInfo extends PostProcessConstant {

    private short classIndex;
    private short nameAndTypeIndex;

    private ConstantClassInfo classRef;
    private ConstantNameAndTypeInfo nameAndTypeInfoRef;

    public ConstantClassMemberInfo(short classIndex, short nameAndTypeIndex) {
        this.classIndex = classIndex;
        this.nameAndTypeIndex = nameAndTypeIndex;
    }

    public short getClassIndex() {
        return classIndex;
    }

    public void setClassIndex(short classIndex) {
        this.classIndex = classIndex;
    }

    public short getNameAndTypeIndex() {
        return nameAndTypeIndex;
    }

    public void setNameAndTypeIndex(short nameAndTypeIndex) {
        this.nameAndTypeIndex = nameAndTypeIndex;
    }

    @Override
    public String getRawString() {
        return "#" + classIndex + ".#" + nameAndTypeIndex;
    }

    @Override
    public String toString() {
        return classRef.toString() + "." + nameAndTypeInfoRef.toString();
    }

    @Override
    public void finish(List<Constant> constants) {
        classRef = (ConstantClassInfo) constants.get(classIndex);
        nameAndTypeInfoRef = (ConstantNameAndTypeInfo) constants.get(nameAndTypeIndex);
    }
}
